package com.example.demo.controller;

import com.example.demo.bean.Cat;
import com.example.demo.service.CatService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Created by ${lgs} on 2018/7/24
 */

@RestController
@RequestMapping("/cat")
public class CatController {

    @Resource
    private CatService catService;

    @RequestMapping("/save")
    public String save() {
        Cat cat = new Cat();
        cat.setCatName("Gong Dog");
        cat.setCatAge(38);
        cat.setPrice(12.52);
        catService.save(cat);
        return "save ok";
    }

    @RequestMapping("/delete")
    public String delete() {
        catService.delete(9);
        return "delete ok";
    }

    @RequestMapping("/getAll")
    public Iterable<Cat> getAll() {
        return catService.getAll();
    }

    @RequestMapping("/findByCatName")
    public Cat findByCatName(String catName) {
        return catService.findByCatName(catName);
    }

    @RequestMapping("/findByCatName2")
    public Cat findByCatName2(String catName) {
        return catService.findByCatName2(catName);
    }

    @RequestMapping("/selectByCatName")
    public Cat selectByCatName(String catName) {
        return catService.selectByCatName(catName);
    }
}
